package gob.osinerg.emergencia.tag;

import org.apache.commons.lang.StringUtils;

public class TimePickerControl extends GenericControl{
	
	private String imgSrc="images/hora/timepicker.gif";
	
	public TimePickerControl() {
		setType("text");
		setControl("input");
		setOnblur("javascript:validateDatePicker(this)");
		setReadonly(false);
	}
	
	public String toString() {
		
		StringBuffer sb = new StringBuffer();
		sb.append("<td width=\"25%\">");
		sb.append(StringUtils.isEmpty(getLabel())?"":getLabel()+" ");
		sb.append("</td>");
		sb.append("<td>");
		openTag(sb);
		sb = getHtml(sb);
		closeTag(sb);
		
		StringBuffer img = new StringBuffer(" <img");
		prepareAttribute(img, "style", "cursor:hand");
		prepareAttribute(img, "src",getImgSrc());
		prepareAttribute(img, "id", getStyleId());
		prepareAttribute(img, "alt", "Seleccione hora inicio");
		prepareAttribute(img, "title", "Hora");
		prepareAttribute(img, "onClick", "javascript:selectTime(this, document.all('"+getName()+"'))");
		closeTag(img);
		sb.append(img.toString());
		sb.append(StringUtils.isEmpty(getRequired())?"":"(*)");
		sb.append("</td>");
		return sb.toString();
	}

	
	public static void main(String[] args) {
		TimePickerControl dp = new TimePickerControl();
		
		System.out.println(dp.toString());
	}
	
	public String getImgSrc() {
		return imgSrc;
	}

	public void setImgSrc(String imgSrc) {
		this.imgSrc = imgSrc;
	}
	
	
	
}
